Telegram Group & Telegram Channel
👍 Команда дня: contextlib.suppress

Сегодня разберём полезную команду для работы с contextlib.suppress — удобный способ игнорировать определённые исключения без громоздкого try-except.

from contextlib import suppress

# Игнорируем FileNotFoundError при удалении файла
with suppress(FileNotFoundError):
import os
os.remove("non_existent_file.txt")


Зачем это нужно:
Упрощает код, когда вы хотите молча пропустить определённые ошибки.
Например, удаление файла, который может не существовать, или обработка данных, где некоторые ключи могут отсутствовать.

Пример из реальной жизни:
data = {"name": "Alice"}
with suppress(KeyError):
print(data["age"]) # Не сломается, даже если ключа "age" нет


Библиотека питониста #буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/pyproglib/6695
Create:
Last Update:

👍 Команда дня: contextlib.suppress

Сегодня разберём полезную команду для работы с contextlib.suppress — удобный способ игнорировать определённые исключения без громоздкого try-except.

from contextlib import suppress

# Игнорируем FileNotFoundError при удалении файла
with suppress(FileNotFoundError):
import os
os.remove("non_existent_file.txt")


Зачем это нужно:
Упрощает код, когда вы хотите молча пропустить определённые ошибки.
Например, удаление файла, который может не существовать, или обработка данных, где некоторые ключи могут отсутствовать.

Пример из реальной жизни:
data = {"name": "Alice"}
with suppress(KeyError):
print(data["age"]) # Не сломается, даже если ключа "age" нет


Библиотека питониста #буст

BY Библиотека питониста | Python, Django, Flask


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/pyproglib/6695

View MORE
Open in Telegram


Библиотека питониста | Python Django Flask Telegram | DID YOU KNOW?

Date: |

Telegram auto-delete message, expiring invites, and more

elegram is updating its messaging app with options for auto-deleting messages, expiring invite links, and new unlimited groups, the company shared in a blog post. Much like Signal, Telegram received a burst of new users in the confusion over WhatsApp’s privacy policy and now the company is adopting features that were already part of its competitors’ apps, features which offer more security and privacy. Auto-deleting messages were already possible in Telegram’s encrypted Secret Chats, but this new update for iOS and Android adds the option to make messages disappear in any kind of chat. Auto-delete can be enabled inside of chats, and set to delete either 24 hours or seven days after messages are sent. Auto-delete won’t remove every message though; if a message was sent before the feature was turned on, it’ll stick around. Telegram’s competitors have had similar features: WhatsApp introduced a feature in 2020 and Signal has had disappearing messages since at least 2016.

Dump Scam in Leaked Telegram Chat

A leaked Telegram discussion by 50 so-called crypto influencers has exposed the extraordinary steps they take in order to profit on the back off unsuspecting defi investors. According to a leaked screenshot of the chat, an elaborate plan to defraud defi investors using the worthless “$Few” tokens had been hatched. $Few tokens would be airdropped to some of the influencers who in turn promoted these to unsuspecting followers on Twitter.

Библиотека питониста | Python Django Flask from ru


Telegram Библиотека питониста | Python, Django, Flask
FROM USA